home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / java / io / StringBufferInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  827 b   |  64 lines

  1. package java.io;
  2.  
  3. public class StringBufferInputStream extends InputStream {
  4.    protected String buffer;
  5.    protected int pos;
  6.    protected int count;
  7.  
  8.    public StringBufferInputStream(String var1) {
  9.       this.buffer = var1;
  10.       this.count = var1.length();
  11.    }
  12.  
  13.    public synchronized int read() {
  14.       return this.pos < this.count ? this.buffer.charAt(this.pos++) & 255 : -1;
  15.    }
  16.  
  17.    public synchronized int read(byte[] var1, int var2, int var3) {
  18.       if (this.pos >= this.count) {
  19.          return -1;
  20.       } else {
  21.          if (this.pos + var3 > this.count) {
  22.             var3 = this.count - this.pos;
  23.          }
  24.  
  25.          if (var3 <= 0) {
  26.             return 0;
  27.          } else {
  28.             String var4 = this.buffer;
  29.             int var5 = var3;
  30.  
  31.             while(true) {
  32.                --var5;
  33.                if (var5 < 0) {
  34.                   return var3;
  35.                }
  36.  
  37.                var1[var2++] = (byte)var4.charAt(this.pos++);
  38.             }
  39.          }
  40.       }
  41.    }
  42.  
  43.    public synchronized long skip(long var1) {
  44.       if (var1 < 0L) {
  45.          return 0L;
  46.       } else {
  47.          if (var1 > (long)(this.count - this.pos)) {
  48.             var1 = (long)(this.count - this.pos);
  49.          }
  50.  
  51.          this.pos = (int)((long)this.pos + var1);
  52.          return var1;
  53.       }
  54.    }
  55.  
  56.    public synchronized int available() {
  57.       return this.count - this.pos;
  58.    }
  59.  
  60.    public synchronized void reset() {
  61.       this.pos = 0;
  62.    }
  63. }
  64.